import 'package:flutter/material.dart';
import 'package:flutter_http_utils/flutter_http_utils.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

import '../../../config/app_colors.dart';

extension AppToastStringExtend on String {
  Future toastInfo([bool isDismiss = true]) async {
    if (isDismiss) {
      //这里不用等待，防止多显示一个
      toastDismiss();
    }
    return SmartDialog.showToast(this);
  }

  SnackbarController snackBar() => Get.snackbar(
        "",
        titleText: SizedBox.shrink(),
        this,
        backgroundColor: ColorsApp.white,
        animationDuration: Duration(milliseconds: 500),
        boxShadows: [
          BoxShadow(color: ColorsApp.gray_97, blurRadius: 10),
        ],
      );
}

extension HttpResponseExtend on HttpResponse {
  Future toastInfo([bool isDismiss = true]) async {
    msg.toastInfo(isDismiss);
  }
}

Future toastDismiss() {
  return SmartDialog.dismiss(status: SmartStatus.allToast);
}
